package com.cy.pj.sys.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
public class Approval {
    private Long approvalId;         //审批表id
    private Integer moduleId;           //模块id
    private Long applicantId;        //申请人id
    private String applicantName;      //申请人姓名
    private Long approverId;         //审批人id
    private String approverName;       //审批人姓名
    private Long processId;          //审批流程id
    private Integer levels;             //审批等级
    private String rejectReason;       //审批驳回原因
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;         //创建时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date modifyTime;         //修改时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date completeTime;       //审批完成时间
    private Integer status;             //审批状态

    public void setProcess(Process process) {
        this.approverId = process.getApproverId();
        this.approverName = process.getApproverName();
        this.processId = process.getProcessId();
        this.levels = process.getLevels();
    }

    public void setApplicant(User user) {
        this.setApplicantId(user.getUserName());
        this.setApplicantName(user.getName());
    }

    public void toDetails(Approval approval) {
        this.setApprovalId(approval.getApprovalId());
        this.setApplicantId(approval.getApplicantId());
        this.setApplicantName(approval.getApplicantName());
        this.setCreateTime(approval.getCreateTime());
        this.setModifyTime(approval.getModifyTime());
        this.setCompleteTime(approval.getCompleteTime());
        this.setStatus(approval.getStatus());
    }
}
